package com.aerospace.serviceprovider.config;

import com.aerospace.serviceprovider.quartz.Quartz;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.QuartzJobBean;

@Configuration
public class QuartzConfig {
    @Bean
    public JobDetail quartzDetail(){
        System.out.println("00000000000000000");
        return JobBuilder.newJob(Quartz.class).withIdentity("quartz").storeDurably().build();
    }

    @Bean
    public Trigger quartzTrigger(){
        SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
                .withIntervalInSeconds(10)
                .repeatForever();
        return TriggerBuilder.newTrigger().forJob(quartzDetail())
                .withIdentity("quartz")
                .withSchedule(scheduleBuilder)
                .build();
    }
}
